package co.yixiang.huiMin.service.impl;

import co.yixiang.huiMin.entity.PriceRange;
import co.yixiang.huiMin.mapper.PriceRangeMapper;
import co.yixiang.huiMin.service.PriceRangeService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 价格区间 服务实现类
 * </p>
 *
 * @author Author
 * @since 2020-07-15
 */
@Service
public class PriceRangeServiceImpl extends ServiceImpl<PriceRangeMapper, PriceRange> implements PriceRangeService {

    @Resource
    private PriceRangeMapper priceRangeMapper;

    @Override
    public int insertPriceRanges(PriceRange priceRange) {
        priceRange.setCreateTime(LocalDateTime.now());
        return priceRangeMapper.insert(priceRange);
    }

    @Override
    public int updatePriceRanges(PriceRange priceRange) {
        return priceRangeMapper.updateById(priceRange);
    }

    @Override
    public List<PriceRange> selectPriceRanges() {
        QueryWrapper<PriceRange> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("is_del",0);
        return priceRangeMapper.selectList(queryWrapper);
    }

    @Override
    public PriceRange selectPriceRangeById(String priceRangeId) {
        return priceRangeMapper.selectById(priceRangeId);
    }
}
